merge_student_teacher__expenditure<-function(){
  setwd(wd_data_final)
  data_student_teacher<-readRDS('data_student_teacher')
  data_expenditure<-readRDS('data_expenditure')
  
  data_expenditure_purchases<-data_expenditure[[1]] %>% 
    filter(ValoareRON<500000) %>%
    group_by(an,judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(ValoareEUR))
  
  data_expenditure_contracts<-data_expenditure[[2]] %>%
    group_by(an,judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(ValoareEUR))
  
  data_expenditure_complete<-rbind(data_expenditure_purchases,data_expenditure_purchases, .id='expenditure_source') %>%
    mutate(expenditure_source=ifelse(expenditure_source==1,'purchases',expenditure_source)) %>% 
    mutate(expenditure_source=ifelse(expenditure_source==2,'contracts',expenditure_source)) %>%
    group_by(judet.bac,unitate_de_invatamant) %>%
    summarise(Expenditure=sum(Expenditure)/length(an))
    
  data_student_teacher_expenditure<-base::merge(data_student_teacher,data_expenditure_complete,by.x=c("judet_bac","unitate_de_invatamant"),by.y=c("judet.bac","unitate_de_invatamant"))
  
  stats<-data_student_teacher_expenditure %>% group_by(an,n_hs_town_group) %>% summarise(n=n())
  stats<-data_student_teacher %>% group_by(an,n_hs_town_group) %>% summarise(n=n())
  
  setwd(wd_data_final)
  saveRDS(data_student_teacher_expenditure,"data_student_teacher_expenditure")
  
  return(data_student_teacher_expenditure)
}